package com.csw.zookeeper;

import org.apache.zookeeper.CreateMode;
import org.apache.zookeeper.ZooDefs;
import org.apache.zookeeper.ZooKeeper;

public class Demo01zk {
    public static void main(String[] args) throws Exception{
        ZooKeeper zk = new ZooKeeper("master:2181,node1:2181,node2:2181",
                30000, null);
        zk.create("/test",//节点
                "test".getBytes()//数据
                ,ZooDefs.Ids.OPEN_ACL_UNSAFE,//节点权限
                CreateMode.EPHEMERAL);//节点类型(临时节点)(永久性节点:CreateMode.PERSISTENT)

        Thread.sleep(10000);//睡眠10秒

//        zk.delete("/data",-1);//删除节点

        zk.close();//关闭节点

    }
}
